package com.example.tutorialspringbootrabbitmq.mq;

import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;

public class MqSender {
    @Autowired
    private AmqpTemplate amqpTemplate;

    public void sendMessage(Object message) {
        System.out.println("发送消息:" + message);

        // Exchange为direct 模式，直接指定routingKey
        amqpTemplate.convertAndSend("dlxKey", "[Direct发送的消息] " + message);
    }
}
